package com.ssm.forum.dao.mapper.residence;

import com.github.pagehelper.PageInfo;
import com.jee.ssm.common.web.param.ParamMap;
import com.ssm.forum.dao.model.residence.Residence;
import com.ssm.upms.dao.mapper.ssm.LzDao;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* 小区管理 Dao
* @author GaoXiang
* @version 1.0
*/
@Repository
public class ResidenceDao extends LzDao<Residence> {



    /**
    * 保存数据
    * @param residence 实体对象
    * @return 实体id
    * @throws Exception 数据保存异常
    */
    public Integer insert(Residence residence) throws Exception {
        return insert("ResidenceMapper.insert",residence);
    }

    /**
    * 根据 id 修改
    * @param residence 带id的实体对象
    * @return 受影响的行数
    * @throws Exception 数据修改异常
    */
    public Integer updateById(Residence residence) throws Exception {
        return update("ResidenceMapper.updateById",residence);
    }

    /**
    * 根据 id 删除
    * @param id 数据id
    * @return 受影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteById(String id) throws Exception {
        return delete("ResidenceMapper.deleteById",id);
    }

    /**
    * 根据 id 查找
    * @param id 实体id
    * @return 实体
    */
    public Residence selectById(String id) {
        return selectOne("ResidenceMapper.selectById",id);
    }

    /**
    * 根据 id 批量删除
    * @param ids 要删除的id
    * @return 影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteByIds(List<String> ids) throws Exception {
        return delete("ResidenceMapper.deleteByIds",ids);
    }

    /**
    * 查询列表
    * @param map 参数
    * @return 列表
    */
    public PageInfo<Residence> list(Map map) {
        return list("ResidenceMapper.list",map);
    }

    /**
    * 查询列表 带分页
    * @param map 参数
    * @param page 页码
    * @param size 每页大小
    * @return 列表
    */
    public PageInfo<Residence> list(Map map, int page, int size) {
        return list("ResidenceMapper.list",map,new RowBounds(page,size));
    }

     public Long countCode(Map map){
        return count("ResidenceMapper.countCode",map);
    }

    public List<Residence> listAll(Residence residence) {
        return arrayList("ResidenceMapper.listAll", residence);
    }

    public List<Residence> countName(Residence residence) {
        return arrayList("ResidenceMapper.countName", residence);
    }

    public Residence countNumber(Residence residence) {
        return selectOne("ResidenceMapper.countNumber", residence);
    }

    public List<Residence> countName2(Residence residence) {
        return arrayList("ResidenceMapper.countName2", residence);
    }

    public Residence countNumber2(Residence residence) {
        return selectOne("ResidenceMapper.countNumber2", residence);
    }

    public List<Residence> chooseResidence(Map map){return  arrayList("ResidenceMapper.chooseResidence",map);}

    public List<Residence> findName(Residence residence) {
        return arrayList("ResidenceMapper.findName", residence);
    }

    public List<Residence> listByEstateId(String estateId) {
        return arrayList("ResidenceMapper.listByEstateId", estateId);
    }


    public List<Residence> listByPoliceId(String policeId) {
        return arrayList("ResidenceMapper.listByPoliceId", policeId);
    }

    public List<Residence> findResidenceByCity(String cityName){
         return arrayList("ResidenceMapper.findResidenceByCity",cityName);
    }
    public List<Residence> findResidenceByArea(String areaName){
         return arrayList("ResidenceMapper.findResidenceByArea",areaName);
    }

    public PageInfo<Residence> resAdminList(String id, int page, int size){
        return list("ResidenceMapper.resAdminList",id,new RowBounds(page,size));
    }

    /**
     * 根据police_id查询
      * @param map
     * @return
     */
    public List<Residence> findByPoliceId(Map map){
        return  arrayList("ResidenceMapper.findByPoliceId",map);
    }

    public List<Residence> listWithoutPage(ParamMap paramMap) {
        return arrayList("ResidenceMapper.listWithoutPage", paramMap);
    }

    public List<Residence> listByAccount(ParamMap p) {
        return arrayList("ResidenceMapper.listByAccount", p);
    }

    /**
     * 根据小区的编号查询
     * @param map 参数
     * @return 实体
     */
    public Residence selectByresCode(Map map){return  selectOne("ResidenceMapper.selectByresCode",map);}
}
